﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_gold_addGoldCard : System.Web.UI.Page
{
    db_gold gold = new db_gold();
    protected void Page_Load(object sender, EventArgs e)
    {
        Server.Execute("../inc/checkPurview.aspx");  // 此处用户权限验证
    }
    protected void btn_ok_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            string sGold = ddl_gold.SelectedValue;
            string num = ddl_num.SelectedValue;

            int iNum = Int32.Parse(num);
            //新建二维数组，[0][]:卡号；[1][]:密码
            string[][] strsql = new string[2][];
            strsql[0] = new string[iNum];
            strsql[1] = new string[iNum];

            //生产卡号数组
            string[] arrID = Tools.createGoldcardID(iNum);
            for (int i = 0; i < iNum; i++)
            {
                strsql[0][i] = arrID[i];
                strsql[1][i] = Tools.createGoldcardPWD(strsql[0][i]);
            }
            if (gold.addGoldCardList(strsql, sGold))
            {
                Response.Write("<script language=javascript>alert('增加成功');</script>");
            }
        }
    }
    protected void cv_gold_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (ddl_gold.SelectedValue.Equals("请选择金币值"))
        {
            args.IsValid = false;
        }
        else
        {
            args.IsValid = true;
        }
    }
    protected void cv_num_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (ddl_num.SelectedValue.Equals("请选择数量"))
        {
            args.IsValid = false;
        }
        else
        {
            args.IsValid = true;
        }
    }
}